<template>
    <view class="box_1">
        <view class="business-record">
            <view class="r-data">
                <view  @tap="hanldeShowData1()"><image class="date_image" src="../../static/img/cash_date.png"></image></view>
                <view class="d-time" @tap="hanldeShowData1()"><input disabled v-model="start_time"  placeholder="开始时间"/></view>
                <view  @tap="hanldeShowData2()"><image class="date_image" src="../../static/img/cash_date.png"></image></view>
                <view class="d-time" @tap="hanldeShowData2()"><input disabled v-model="end_time" placeholder="结束时间"/></view>
                <view class="business_number">
                    <view @tap="clear"><button class="button_1">清除</button></view>
                    <view><button class="button_1" @tap="submit">搜索</button></view>
                </view>
            </view>
            <view class="r-list" v-if="businessList.length>0">
                <view class="total_cash">累计提现:{{total_cash}}</view>
                <view class="l-box" v-for="(item,index) in businessList" :key="index">
                    <view class="b-num">
                        <view class="n-title">提现到银行卡:尾号({{item.bank_number}})</view>
                        <view class="n-money">{{item.price}}</view>
                    </view>
                    <view class="b-time">
                        <view class="t-title">{{item.created_at}}</view>
                        <view class="t-status">{{item.is_published_name}}</view>
                    </view>
                </view>
            </view>
            <view v-else>
                <mNodata></mNodata>
            </view>
        </view>

        <van-calendar
                type="single"
                :min-date="minDate"
                :max-date="maxDate"
                :show="beginShowData"
                :default-date="defaultDate"
                :title="'选择开始日期'"
                :close-on-click-overlay="true"
                @close="handleCloseData"
                @confirm="handleSubmitData1"
        />
        <van-calendar
                type="single"
                :min-date="minDate"
                :max-date="maxDate"
                :show="endShowData"
                :default-date="defaultDate"
                :title="'选择结束日期'"
                :close-on-click-overlay="true"
                @close="handleCloseData"
                @confirm="handleSubmitData2"
        />
        <m-bottom></m-bottom>
    </view>
</template>

<script>
    export default {
        name: "getChargeList",
        data() {
            return {
                businessList:[],
                beginShowData:false,
                endShowData:false,
                minDate: new Date(2020, 0, 1).getTime(),
                maxDate: new Date().getTime(),
                defaultDate:new Date().getTime(),
                start_time:'',
                end_time:'',
                total_cash:'',
                page:1,
                is_load:0
            }
        },
        mounted() {
            this.getCashList()
        },
        onReachBottom() {  //分页加载请求数据
            if(this.is_load>0){
                this.page++
                setTimeout(()=>{
                    this.getCashList()
                },1000)

            }else{
                uni.showToast({
                    title:"没有更多数据啦",
                    icon:"none",
                })
            }

        },
        methods: {
            //展示日期
            hanldeShowData1(res){
                this.beginShowData=true
            },
            hanldeShowData2(res){
                this.endShowData=true
            },
            //关闭日期弹窗
            handleCloseData(res){
                this.endShowData=false
                this.beginShowData=false
            },
            //选择日期完成后
            handleSubmitData1(res){
                let year=res.detail.getFullYear()
                let month=res.detail.getMonth()+1
                let day=res.detail.getDate()
                this.start_time=year+'-'+month+'-'+day
                this.endShowData=false
                this.beginShowData=false

            },
            handleSubmitData2(res){
                let year=res.detail.getFullYear()
                let month=res.detail.getMonth()+1
                let day=res.detail.getDate()
                this.end_time= year+'-'+month+'-'+day
                this.endShowData=false
                this.beginShowData=false

            },
            clear(){
                this.start_time=''
                this.end_time=''
            },
            async getCashList(){ //获取列表
                uni.showLoading({})
                let resData=await  this.$apis.getCashList({page:this.page,start_time:this.start_time,end_time:this.end_time})
                if (resData.code===0){
                    this.businessList.push(...resData.data.lists)
                    this.is_load=resData.data.is_load
                    this.total_cash=resData.data.total_price
                }
                uni.hideLoading()
            },
            async submit(){ // 点击搜索
                this.page=1
                this.is_load=0
                this.businessList=[]
                await this.getCashList()
            }
        },
    }
</script>
<style>
    page {
        background-color:#FAFAFA
    }
</style>
<style lang="less" scoped>
    .business-record{
        background-color: #ffffff;
        position: relative;
        width: 650rpx;
        margin-left: 50rpx;
        .r-data{
            position: fixed;
            background-color: #ffffff;
            width: 650rpx;
            height: 80rpx;
            display: flex;
            box-sizing: border-box;
            padding: 0 30rpx;
            justify-content: space-between;
            align-items: center;
            border-bottom: solid 1px #EDEDED;
            .d-time{
                font-size: 25rpx;
                color: #333333;
                width: 150rpx;
                margin-left:12rpx;

            }
            .date_arrow_image{
                position: relative;
                width: 40rpx;
                height: 40rpx;
                /*margin-left: -120rpx;*/
            }
        }
        .r-list{
            width: 100%;
            box-sizing: border-box;
            padding: 80rpx 20rpx 0 20rpx;
            .l-box{
                box-sizing: border-box;
                border-bottom: solid 1px #EDEDED;
                padding: 40rpx 0;
                .b-num{
                    display: flex;
                    justify-content: space-between;
                    // line-height: 80rpx;
                    .n-title{
                        font-size: 26rpx;
                        color: #333333;

                    }
                    .n-money{
                        font-size: 26rpx;
                        color: #333333;

                    }
                }
                .b-time{
                    padding-top: 20rpx;
                    display: flex;
                    justify-content: space-between;
                    // line-height: 80rpx;
                    .t-title{
                        font-size: 24rpx;
                        color: gray;
                    }
                    .t-status{
                        font-size: 24rpx;
                        color:gray;
                    }
                }
            }
        }
    }
    .business_number{
        display: flex;
        flex-direction: row;
        width: 226rpx;
        /*border: solid 0.5px #999999;*/
        border-radius: 10px;
        font-size: 25rpx;
        margin-right: -9px;
    }
    .search_image{
        margin-top: 7rpx;
        height: 35rpx;
        width: 35rpx;
    }
    .date_image{
        /*margin-left: 12rpx;*/
        height: 30rpx;
        width: 30rpx;
    }
    .empty_img{
        margin-top: 200rpx;
        width: 520rpx;
        height: 360rpx;
    }
    .empty_text{
        color: #333333;
        font-size: 26rpx;
        margin-top: 20rpx;
    }
    .empty_box{
        text-align: center;
    }
    .button_1{
        width: 108rpx;
        border: none;
        background-color: #FF9502;
        font-size:26rpx;
        color: #ffffff;
    }
    .button_1:nth-child(1){
        margin-right: 10rpx;
    }
    .total_cash{
        font-size: 26rpx;
        color: #F19317;
    }
</style>
